<!DOCTYPE html>
<html>
    <head>
        <link rel="shortcut icon" href="./favicon.svg" type="image/svg+xml"/>
        <link rel="stylesheet" href="./vender/jquery/zTreeStyle/zTreeStyle.css" type="text/css">
        <script src = "./vender/jquery/jquery.js"></script>
        <script src = "./vender/jquery/jquery.ztree.core.min.js"></script> 
        <script src = "./vender/jquery/jquery.ztree.exedit.min.js"></script>
        <script src = "./vender/jquery/jquery.ztree.exhide.min.js"></script>
        <script src = "./vender/fabric.js"></script>
    <!-- 
    局域网环境, 请去 https://www.x-emr.cn/developer 下载 以下文件放置到 public 目录
        ├─public
            ├─js
            │   editor.js    //编辑器主程序代码      (必选)
            │   editor.css   //编辑器工具栏样式         (必选)
            │   doc.css      //病历文档样式
    -->
        <script src="https://www.x-emr.cn/js/editor.js"></script> 
        <link rel='stylesheet' href='https://www.x-emr.cn/js/editor.css' />
    <!-- 局域网配置
        <script src="./js/editor.js"></script>
        <link rel='stylesheet' href='./js/editor.css' />
    -->
        <script>
          $(function() {
            //配置项可以不设置，会使用默认设置
            let option = {
                mode:'form',  //默认模式 form:表单模式，design:设计模式
                docStyle:'https://www.x-emr.cn/js/doc.css', // CSS引用路径
                pdfUrl:'https://www.x-emr.cn/pdf/post',  //pdf生成服务
                dictionary: [  //知识库
                    {type:'symptoms', title: '体征', isParent:true, treeUrl:'https://www.x-emr.cn/dict', itemUrl:'https://www.x-emr.cn/dictitem'},
                    {type:'signs', title: '症状', isParent:true, treeUrl:'https://www.x-emr.cn/dict', itemUrl:'https://www.x-emr.cn/dictitem'},
                    {type:'meta', title: '卫生信息数据元', isParent:true, treeUrl:'https://www.x-emr.cn/dict', itemUrl:'https://www.x-emr.cn/dictitem'},
                    {type:'stand', title: '电子病历数据集', isParent:true, treeUrl:'https://www.x-emr.cn/dict', itemUrl:'https://www.x-emr.cn/dictitem'},
                    {type:'insutance', title: '国家医保标准', isParent:true, treeUrl:'https://www.x-emr.cn/insutance', itemUrl:'https://www.x-emr.cn/institem'},
                    {type:'province', title: 'A省数据平台标准', isParent:true, treeUrl:'https://www.x-emr.cn/province', itemUrl:'https://www.x-emr.cn/provitem'},
                ]
            }

            //用于父页面调用
            if(window.frameElement){
                //1.初始化前
                let e1 = new Event('before-init')
                e1.editor = editor
                e1.option = option
                window.frameElement.dispatchEvent(e1)

                if(window.frameElement.getAttribute('mode')) {
                    option.mode = window.frameElement.getAttribute('mode')
                }
                //2.编辑器初始化
                editor.init(option)

                //如果有组件有doc属性
                if(window.frameElement.getAttribute('doc')) {
                    editor.loadUrl(window.frameElement.getAttribute('doc'), '1').then(function(){
                        let e3 = new Event('doc-loaded')
                        e3.editor = editor
                        window.frameElement.dispatchEvent(e3)
                    })
                }
                
                //3.初始化后
                let e2 = new Event('after-init')
                e2.editor = editor
                window.frameElement.dispatchEvent(e2)
            }
          })
      </script>
    </head>
    <body>
        <!-- 默认id 为editor -->
        <div id="editor" style="width:100%; height:100%;"></div>
    </body>
</html>
